package com.skynet.supervision.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.skynet.supervision.utils.TimeUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * mybatis-plus自动填充功能
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createTime", Long.class, TimeUtils.nowUnix());
        this.strictInsertFill(metaObject, "updateTime", Long.class, TimeUtils.nowUnix());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "updateTime", Long.class, TimeUtils.nowUnix());
    }
}